package com.wn.class30.cotroller.weixin;

import com.wn.class30.entity.Myorder;
import com.wn.class30.service.OrderService;
import com.wn.class30.tools.Result;
import com.wn.class30.tools.UseridUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RequestMapping(value = "/weixin")
@RestController
@Api(value = "订单功能",tags ="订单功能")
public class MyOrderController {
    @Resource
    private OrderService orderService;
    @Resource
    private UseridUtils useridUtils;
    @GetMapping(value = "/queryOrder")
    @ApiOperation(value = "查询所有订单",notes = "查询所有订单")
    public Result queryOrder(HttpServletRequest req) throws Exception {
        Integer userid = useridUtils.queryUseridByOptenid(req);
        if(userid!=null){
        List<Myorder> myorders = orderService.queryOrderByUserId(userid);
        return new Result("200","success",null,myorders);
        }
        return new Result("200","success",null,null);
    }
}
